/*
 * Copyright (C) 2010 Wim Crols <twimpiex@gnx.be>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License Version 3
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

package be.gnx.event.consumer.receiver.logback;

import java.util.HashMap;
import java.util.Map;

import be.gnx.event.consumer.receiver.EventProcessor;
import ch.qos.logback.classic.spi.ILoggingEvent;

public class LogbackEventProcessor extends EventProcessor {

	private static final LogbackEventProcessor logbackEventProcessor = new LogbackEventProcessor();

	private LogbackEventProcessor() {
		super();
	}

	public static LogbackEventProcessor getInstance() {
		return logbackEventProcessor;
	}

	@Override
	public void eventReceived(Object event, String client) {
		if (event instanceof ILoggingEvent) {
			// TODO first unmangle this event into a map of attributes
			Map<String, String> eventProperties = new HashMap<String, String>();
			eventReceived(eventProperties, event, client);
		} else {
			System.err.println("event is not an instance of ILoggingEvent but "
					+ event.getClass());
		}
	}

}
